package com.example.demo.controller;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping("/Ai")
public class AiController {

    @Autowired
    @Qualifier("chat")
    private ChatClient chat;

    @Autowired
    @Qualifier("gameChat")
    private ChatClient gameChat;

    @PostMapping("/chat")
    public Flux<String> chat(String prompt){
        return chat.prompt().user(prompt).stream().content();

    }

    @PostMapping("/ChatXiShi")
    public Flux<String> ChatXiShi(String prompt){
        return gameChat.prompt().user(prompt).stream().content();
    }
}
